<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录PL博客</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
    <form method="post">
    <div class="model">

        <header class="bg-blue">登录PL博客</header>
        <div class="login-body">
          <div>
            <label for="username">账号&nbsp;&nbsp;&nbsp;</label>
            <input class="username" type="text" name="username" required="true">
          </div>
          <div>
            <label for="password">密码&nbsp;&nbsp;&nbsp;</label>
            <input class="password" type="password" name="password" required="true">
          </div>
          <div>
            <input type="checkbox" id="rem" class="colored-blue" value="true">                   
            <span class="text">记住密码</span>
          </div>
          <div style="text-align: right;margin-right: 52px;font-size: 11px;margin-bottom: 11px;margin-top: -17px;">
          	<a href="register.jsp">没有账号？前去注册>></a>
          </div>
          <div>
            <input id="loginBtn" type="submit" value="登陆">
            <input type="reset" value="重置">
          </div>
        </div>

    <div>
      </form>
  </body>
</html>
<script src="js/jquery.min.js"></script>
<script>
$("form").submit(function(){
    //这里是要执行的代码
    event.preventDefault();
});
  $("#loginBtn").click(function(){
    var username = $(".username").val();
    var pwd = $(".password").val();
    var rem = $("#rem").is(':checked');
    $.post("login_action.jsp",{
    	username:username,
    	pwd:pwd,
    	rem:rem
    },function(res){
    	if(res=="true"){
    		sessionStorage.username = username;
    		
    		location.href="index.jsp?username="+username;
    	}else{
    		alert(res);
    	}
    });
  });
  document.onkeyup = function(e){
    var ev = document.all ? window.event : e;
    if(ev.keyCode==13) {
      $("#loginBtn").click();
     }
  }
</script>
